<template>
  <div class="content">
     <el-form ref="form" :model="form" >
    <div class="search">
        <el-form-item label="姓名" class="label">
          <el-input v-model="form.name" class="input" placeholder="请输入姓名"></el-input>
        </el-form-item>
        <el-form-item label="身份证" class="label">
          <el-input v-model="form.name" class="input" placeholder="请输入身份证"></el-input>
        </el-form-item>
         <el-form-item label="审核状态" class="label">
           <el-select placeholder="请选择审核状态" class="input"></el-select>
         <!--  <el-input v-model="form.name" class="input"></el-input> -->
        </el-form-item>
         <el-form-item >
            <el-button type="primary" @click="onSubmit" size="mini">查询</el-button>
          </el-form-item>
          <!-- <el-button @click="download">下载</el-button> -->
           <el-form-item style="width:100%;">
           <div style="float:right;">
              <img src="../../assets/T通用按钮/按钮/导出.png" alt="">
           </div>

        </el-form-item>
    </div>
    </el-form>
    <el-table
    ref="singleTable"
    :data="tableData"
    :header-cell-style="{background: '#EBECF0',height:'44px',color:'#000000'}"
    :cell-style="{background: '#ffffff',height:'44px',color:'#000000'}"
    highlight-current-row
    @current-change="handleCurrentChange"
    style="width: 100%">
    <el-table-column
      label="序号"
      type="index"
      width="100">
    </el-table-column>
    <el-table-column
      property="name"
      label="姓名"
      >
    </el-table-column>
       <el-table-column

      label="身份证">
      <template slot-scope="scope">
        {{scope.row.idNum | hideidCard}}
      </template>
    </el-table-column>
    <el-table-column
      property="phone"

      label="手机号">
    </el-table-column>
     <el-table-column
      property="community"

      label="小区">
    </el-table-column>
     <el-table-column
      property="door"

      label="单元-门牌-房间">
    </el-table-column>
     <el-table-column
      property="time"

      label="时间">
    </el-table-column>
     <el-table-column
      property="address"

      label="状态">
    </el-table-column>
    <el-table-column
      property="address"
      width="150"
      label="采集图片">
      <template slot-scope="scope">
       <img :src="scope.row.img" class="img" alt="" @click="showImg(scope.row.img)">
      </template>
    </el-table-column>
  </el-table>
  <div class="pagination">
      <el-pagination
        :current-page.sync="page"
        background
        :page-sizes="[10, 20, 30, 40]"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @current-change="handleCurrentChange"
      />
  </div>
  <!-- 图片放大 -->
    <img-dialog v-if="isShownimg" :img="chooseImg" @closeImg="closeImg"></img-dialog>



  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import ImgDialog from '@/components/Imgdialog'
import table2excel from '@/utils/js-table2excel'
export default {
  name: 'Dashboard',
  data() {
    return {
      form:{

      },
      tableData:[
         {name:'111',idNum:'230211199702171837',phone:'18796231777',community:'新丰苑三期',door:'2-1-1002',time:'2020-02-21',img:'https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/b3b39c89c7384b9e8fae08d35660e1b7~tplv-k3u1fbpfcp-watermark.image',demo:'555s'}
        ,
       {name:'111',idNum:'230211199702171837',phone:'18796231777',community:'新丰苑三期',door:'2-1-1002',time:'2020-02-21',img:'https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/b3b39c89c7384b9e8fae08d35660e1b7~tplv-k3u1fbpfcp-watermark.image'}
      ],
      total:100,
      page:10,
      isShownimg:false,
      chooseImg:null
    }
  },
  computed: {
    ...mapGetters([
      'communityId'
    ])
  },
   components:{
    ImgDialog
  },
  created() {

  },
  methods: {
    showImg(img){
      this.isShownimg=true
      this.chooseImg=img
    },
    closeImg(){
      this.isShownimg=false
    },
    download(){

      const column = [
        {
          title: '姓名',
          key: 'name',
          type: 'text',
          width:200,
          height: 60
        },
        {
          title: '图片',
          key: 'img',
          type: 'image',
          width: 200,
          height: 60
        },{
          title: '测试数据',
          key: 'demo',
          type: 'text',
          width: 100,
          height: 60
        }
      ]
      var table=[]
      for(var i=0;i<3;i++){
        table.push(this.tableData[0])
      }
      const data = table
      const excelName = 'test.xlsx'
      table2excel(column, data, excelName)
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v => filterVal.map(j => v[j]))
    }
  },
  watch: {
    communityId(newVal,oldVal){
      console.log('changed')
    }
  },
}
</script>
<style lang="scss" scoped>
.content{
  background: #ffffff;
  padding:25px;
  padding-bottom: 100px;
  min-height: 800px;
  position: relative;
  .search{
    display: flex;
    align-items: flex-end;
    border-bottom: 2px solid #DCDEE3;
    margin-bottom: 30px;
    img {
      vertical-align: middle;
    }
  }
  .input{
    width: 346px;
  }
  .label{
    margin-right: 20px;
    color: #666666;
    font-size: 14px;
  }
  .pagination{
    position: absolute;
    right: 0;
    bottom: 0;
    margin: 50px;
  }
  .img{
    width: 50px;
    height: 34px;
  }
}
</style>
<style>
.input .el-input__inner{
   height: 28px !important;
}
</style>
